package iscript.uiFramework.components.mask 
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	import iscript.uiFramework.components.UIComponent;
	import iscript.uiFramework.UIFramework;

	public class MaskComponent extends UIComponent
	{
		
		public function MaskComponent() 
		{
			
		}
		
		private var _maskBitmap:Bitmap;
		override protected function initialize():void 
		{
			super.initialize();
			//this.name = "b35d70ec-90c4-40dc-ac09-48867bd0b1b2";
			//_maskBitmap = new Bitmap(UIFramework.resource.getBitmapData("GameLite.UIComponent.DefaultTheme.Mask"));
			_maskBitmap = new Bitmap(new BitmapData(1, 1, false, 0x585858));
			_maskBitmap.alpha = 0.3;
			_maskBitmap.width = UIFramework.UiStage.stageWidth;
			_maskBitmap.height = UIFramework.UiStage.stageHeight;
			addChild(_maskBitmap);
			UIFramework.UiStage.addEventListener(Event.RESIZE, _maskResizeLogic);
			_maskBitmap.addEventListener(Event.REMOVED_FROM_STAGE,_removeFormStageLogic)
		}
		
		private function _removeFormStageLogic(e:Event):void 
		{
			removeEventListener(Event.REMOVED_FROM_STAGE, _removeFormStageLogic);
			UIFramework.UiStage.removeEventListener(Event.RESIZE, _maskResizeLogic);
			_maskBitmap.removeEventListener(Event.REMOVED_FROM_STAGE,_removeFormStageLogic)
		}
		
		private function _maskResizeLogic(e:Event):void 
		{
			_maskBitmap.width = UIFramework.UiStage.stageWidth;
			_maskBitmap.height = UIFramework.UiStage.stageHeight;
		}
		
		override public function dispose():void 
		{
			if (!Disposed) {
				super.dispose()
			  if (this.parent != null) this.parent.removeChild(this);	 
		    }
		}
		
	}

}